home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
001-100
/
001-025
/
004
/
bm
/
matchfound.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-03-17
|
1KB
|
33 lines
#include <stdio.h>
#include "bm.h"
#include "Extern.h"
MatchFound(Desc, BuffPos, Buffer, BuffEnd)
struct PattDesc *Desc; /* state info about search for one string */
int BuffPos; /* offset of first char of buffer into the file being searched */
char *Buffer, /* pointer to the first character in the buffer */
*BuffEnd; /* pointer to the last character in the buffer */
{
char *MLineBegin, *MLineEnd;
Desc->Success = 0;
/* Start points to first character after a successful match */
MLineBegin = MLineEnd = Desc->Start - 1;
while(MLineBegin >=Buffer && *MLineBegin != '\n') --MLineBegin;
++MLineBegin;
while( MLineEnd <= BuffEnd && *MLineEnd != '\n') ++MLineEnd;
if (MLineEnd > BuffEnd) --MLineEnd;
/* fixed 25jun85 pdbain. suppress multiple matches of the same
* pattern on one line */
Desc->Start = MLineEnd + 1;
/* check if exact match */
if (xFlag && !( Desc->PatLen == (*MLineEnd != '\n' ? ((MLineEnd -
MLineBegin) + 1) : (MLineEnd - MLineBegin))))
return(0); /* failure */
if (sFlag) return(1);
if (cFlag) {
++MatchCount;
return(1);
} /* if */
PrintLine(BuffPos+(Desc->Start-Buffer),MLineBegin,MLineEnd);
return(1);
} /* MatchFound */